package com.yipao.admin.web;

import com.yipao.admin.service.LbsTableService;
import com.yipao.db.domain.devinfo.DevInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author Like
 */
@RestController
@RequestMapping("/admin/map")
@Validated
public class AdminMapController {

    @Autowired
    private LbsTableService service;

    /**
     * 新增一条地图数据
     * @param model
     * @return
     */
    @PostMapping("/insert")
    public Object insert(@RequestBody DevInfo model){

        return service.insert(model);
    }

    /**
     * 更新一条地图数据
     * @param model
     * @return
     */
    @PostMapping("/update")
    public Object update(@RequestBody DevInfo model){
        return service.update(model);
    }

    /**
     * 根据id删除
     * @param id
     * @return
     */
    @PostMapping("/delete")
   public Object deleteById(@RequestParam("id") String id){

        return service.deleteById(id);
   }

   @GetMapping("/findAll")
    public Object findAll(){

        return service.list();
   }

   @GetMapping("/searchNearby")
    public Object searchNearby(@RequestParam("keyword")String keyword,
                               @RequestParam("location")String location
   ){
        return service.searchNearby(keyword, location);
   }



}
